import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;


public class Hand<T extends Scorable> implements Collection<Scorable>, Scorable
{
    private ArrayList<Scorable> _hand;
    private int _score;
    
    public Hand(int numberOfObjects)
    {
    	_hand = new ArrayList<Scorable>(numberOfObjects);
    }

    public int getScore()
    {
        return _score;
    }

    @Override
    public boolean add(Scorable arg0)
    {
    	_score += arg0.getScore();
        return _hand.add(arg0);
    }

    @Override
    public boolean addAll(Collection<? extends Scorable> arg0)
    {
        return _hand.addAll(arg0);
    }

    @Override
    public void clear()
    {
        _score = 0;
        _hand.clear();
    }

    @Override
    public boolean contains(Object arg0)
    {
        return _hand.contains(arg0);
    }

    @Override
    public boolean containsAll(Collection<?> arg0)
    {
        return _hand.containsAll(arg0);
    }

    @Override
    public boolean isEmpty()
    {
        return _hand.isEmpty();
    }

    @Override
    public Iterator<Scorable> iterator()
    {
        return _hand.iterator();
    }

    @Override
    public boolean remove(Object T)
    {
    	boolean found = false;
    	for(int i = 0; i < _hand.size(); i ++)
    	{
    		if(_hand.get(i) == T)
    		{
    			_hand.remove(T);
    			found = true;
    		}
    	}
    	
    	return found;
    }

    @Override
    public boolean removeAll(Collection<?> arg0)
    {
        return _hand.removeAll(arg0);
    }

    @Override
    public boolean retainAll(Collection<?> arg0)
    {
        return _hand.retainAll(arg0);
    }

    @Override
    public int size()
    {
        return _hand.size();
    }

    @Override
    public Object[] toArray()
    {
        return _hand.toArray();
    }

    @Override
    public <T> T[] toArray(T[] arg0)
    {
        return _hand.toArray(arg0);
    }

}